﻿/* 
 * Since 2008 - 2013
 */

package com.hh.bss.oa.service.impl;

import static com.hh.bss.util.ObjectUtils.isNotEmpty;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import com.hh.bss.base.*;
import com.hh.bss.common.MapObjectRowMapper;
import com.hh.bss.common.exception.SystemException;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.oa.dao.*;
import com.hh.bss.oa.entity.*;
import com.hh.bss.oa.service.*;
import com.hh.bss.oa.vo.query.*;
import com.hh.bss.util.*;





@Service
@Transactional
public class OaMeetingRoomTakingServiceImpl extends BaseBusinessService<OaMeetingRoomTaking,java.lang.Integer>  implements OaMeetingRoomTakingService<OaMeetingRoomTaking,java.lang.Integer>{

	private OaMeetingRoomTakingDao oaMeetingRoomTakingDao;
	private OaMeetingRoomDao oaMeetingRoomDao;
	private OaMeetingRoomLogService oaMeetingRoomLogService;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setOaMeetingRoomTakingDaoImpl(OaMeetingRoomTakingDao dao) {
		this.oaMeetingRoomTakingDao = dao;
	}
	public void setOaMeetingRoomDaoImpl(OaMeetingRoomDao dao) {
		this.oaMeetingRoomDao = dao;
	}
	public void setOaMeetingRoomLogServiceImpl(OaMeetingRoomLogService service) {
		this.oaMeetingRoomLogService = service;
	}
	public EntityDao getEntityDao() {
		return this.oaMeetingRoomTakingDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(OaMeetingRoomTakingQuery query) {
		return oaMeetingRoomTakingDao.findPage(query);
	}
	public void save(OaMeetingRoomTaking entity) throws DataAccessException{
		//检查是否有冲突的预定
		List l=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTaking t where t.status='A' and ( (t.periodType=1 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')>=CURDATE()) or  t.periodType=2 or t.periodType=3 or t.periodType=4)");
		
		
		OaMeetingRoomTaking task;
		for(int i=0;l!=null&&i<l.size();i++){
			task=(OaMeetingRoomTaking)l.get(i);
			if (isConflict(entity,task)) throw new SystemException("存在冲突的预订:["+task.getTitle()+"],开始日期"+DateHelper.toString(task.getOrderDate(), "yyyy-MM-dd")+",开始时间："+DateHelper.toString(task.getBeginDt(), "HH:mm")+",结束时间："+DateHelper.toString(task.getEndDt(), "HH:mm")); 
		}
		getEntityDao().save(entity);
	}
	public void update(OaMeetingRoomTaking entity) throws DataAccessException{
		//检查是否有冲突的预定
		List l=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTaking t where t.status='A' and ( (t.periodType=1 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')>=CURDATE()) or  t.periodType=2 or t.periodType=3 or t.periodType=4)");
		
		
		OaMeetingRoomTaking task;
		for(int i=0;l!=null&&i<l.size();i++){
			task=(OaMeetingRoomTaking)l.get(i);
			if (task.getId().equals(entity.getId())) continue;
			if (isConflict(entity,task)) throw new SystemException("存在冲突的预订:["+task.getTitle()+"],开始日期"+DateHelper.toString(task.getOrderDate(), "yyyy-MM-dd")+",开始时间："+DateHelper.toString(task.getBeginDt(), "HH:mm")+",结束时间："+DateHelper.toString(task.getEndDt(), "HH:mm")); 
		}
		getEntityDao().update(entity);
	}
	public boolean isConflict(OaMeetingRoomTaking newt, OaMeetingRoomTaking oldt){
		return isConflict(newt,oldt,null);
	}
    public boolean isConflict(OaMeetingRoomTaking newt, OaMeetingRoomTaking oldt,Map cancel){
		
		String newOrderDateStr=DateHelper.toString(newt.getOrderDate(), "yyyyMMdd");
		String oldOrderDateStr=DateHelper.toString(oldt.getOrderDate(), "yyyyMMdd");
		
		java.util.Date newOrderDate = DateHelper.toDate(DateHelper.toString(newt.getOrderDate(), "yyyyMMdd"), "yyyyMMdd");
	    java.util.Date oldOrderDate = DateHelper.toDate(DateHelper.toString(oldt.getOrderDate(), "yyyyMMdd"), "yyyyMMdd");
		
		int newTimeBeginInt=StringHelper.parseInt(DateHelper.toString(newt.getBeginDt(), "HHmm"), 0);
		int newTimeEndInt=StringHelper.parseInt(DateHelper.toString(newt.getEndDt(), "HHmm"), 0);
		int oldTimeBeginInt=StringHelper.parseInt(DateHelper.toString(oldt.getBeginDt(), "HHmm"), 0);
		int oldTimeEndInt=StringHelper.parseInt(DateHelper.toString(oldt.getEndDt(), "HHmm"), 0);
		
		//System.out.println("啊啊啊old:"+oldOrderDate+" orid:"+oldt.getRoomId()+" ob:"+DateHelper.toString(oldt.getBeginDt(), "HHmm")+" oe:"+DateHelper.toString(oldt.getEndDt(), "HHmm")+ "----new :"+newOrderDate+" nb:"+" nrid:"+newt.getRoomId()+DateHelper.toString(newt.getBeginDt(), "HHmm")+" ne:"+DateHelper.toString(newt.getEndDt(), "HHmm"));
		
		//新的预订日期不能超过31天
		int ds=DateHelper.getDiffDay(newt.getOrderDate(), new Date());
		int diffd=DateHelper.getDiffDay(newt.getOrderDate(), oldt.getOrderDate());
		if (ds>31) return true;
		
		//比较会议室
		OaMeetingRoom oldOaMeetingRoom=(OaMeetingRoom)oaMeetingRoomDao.getById(oldt.getRoomId());
		OaMeetingRoom newOaMeetingRoom=(OaMeetingRoom)oaMeetingRoomDao.getById(newt.getRoomId());
		
		String newmeetings=newOaMeetingRoom.getId().toString();
		if (newOaMeetingRoom.getType().intValue()==2){
			newmeetings=newOaMeetingRoom.getMeetings();			
		}
		String oldmeetings=oldOaMeetingRoom.getId().toString();
		if (oldOaMeetingRoom.getType().intValue()==2){
			oldmeetings=oldOaMeetingRoom.getMeetings();			
		}
		boolean roomHasConflict=false;
		String[] newms=newmeetings.split(",");
		String[] oldms=oldmeetings.split(",");
		
		for(int i=0;i<newms.length;i++){
			for(int j=0;j<oldms.length;j++){
				if (newms[i].equals(oldms[j])) roomHasConflict=true;
			}
		}
		
		//System.out.println("begin: newmeetings:"+newmeetings+"  oldmeetings:"+oldmeetings);
		if (!roomHasConflict) {
			
			return false;			
		}
		//System.out.println("end: newmeetings:"+newmeetings+"  oldmeetings:"+oldmeetings);
		//----------------
		
		if (cancel==null){
			List values = new ArrayList();
			
			values.add(oldt.getId());
			values.add(newOrderDate);
			List l2=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTakingCancel t where t.taskId=? and t.meetingDate=? ",values.toArray());
			if (l2!=null&&l2.size()>0){
				return false;
			}
		}else{
			if (cancel.containsKey(oldt.getId().toString()+DateHelper.toString(newt.getOrderDate(), "yyyyMMdd"))) return false;
		}
		
		
		if (oldOaMeetingRoom.getType().equals(newOaMeetingRoom.getType())){
			if (!oldOaMeetingRoom.getId().equals(newOaMeetingRoom.getId())) return false;
		}
		
		//新的是指定天的
		if (newt.getPeriodType().intValue()==1){
			//旧的是一天的
			if (oldt.getPeriodType().intValue()==1){
				
				if (newOrderDateStr.equals(oldOrderDateStr)){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;					
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
				
			}else if (oldt.getPeriodType().intValue()==2){
				//旧的是每天 
				if (oldt.getOrderDate().before(newt.getOrderDate())||oldOrderDate.equals(newOrderDate)){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}else if (oldt.getPeriodType().intValue()==3){
				//旧的是每周的
				if (diffd%7==0&&(oldt.getOrderDate().before(newt.getOrderDate())||oldOrderDate.equals(newOrderDate))){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}else if (oldt.getPeriodType().intValue()==4){
				//旧的是每两周的
				if (diffd%14==0&&(oldt.getOrderDate().before(newt.getOrderDate())||oldOrderDate.equals(newOrderDate))){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}
			
		}
		//新的是每天的
		else if (newt.getPeriodType().intValue()==2){
			//旧的是一天的
			if (oldt.getPeriodType().intValue()==1){
			
				if (oldOrderDate.equals(newOrderDate)||oldOrderDate.after(newOrderDate)){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
				
			}else if (oldt.getPeriodType().intValue()==2){
				//旧的是每天 			
				if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
				if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
			}else if (oldt.getPeriodType().intValue()==3){
				//旧的是每周的				
				if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
				if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
			}else if (oldt.getPeriodType().intValue()==4){
				//旧的是每两周的				
				if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
				if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
		    }
		}
		//新的是每周的
		else if (newt.getPeriodType().intValue()==3){
			//旧的是一天的
			if (oldt.getPeriodType().intValue()==1){
			
				
				if (diffd%7==0&&(oldOrderDate.equals(newOrderDate)||oldOrderDate.after(newOrderDate))){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
				
			}else if (oldt.getPeriodType().intValue()==2){
				//旧的是每天 			
				if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
				if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
			}else if (oldt.getPeriodType().intValue()==3){
			   //旧的是每周的
				
				if (diffd%7==0){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}else if (oldt.getPeriodType().intValue()==4){
			   //旧的是每周的				
				if (diffd%14==0){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}	
				
			
		}
		//新的是两周的
		else if (newt.getPeriodType().intValue()==4){
			//旧的是一天的
			if (oldt.getPeriodType().intValue()==1){			
				
				if (diffd%14==0&&(oldOrderDate.equals(newOrderDate)||oldOrderDate.after(newOrderDate))){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
				
			}else if (oldt.getPeriodType().intValue()==2){
				//旧的是每天 			
				if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
				if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
			}else if (oldt.getPeriodType().intValue()==3){
			   //旧的是每周的
				
				if (diffd%14==0){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}else if (oldt.getPeriodType().intValue()==4){
			   //旧的是每周的				
				if (diffd%14==0){
					if ((oldTimeBeginInt<=newTimeBeginInt&&oldTimeEndInt>=newTimeBeginInt)||(oldTimeBeginInt<=newTimeEndInt&&oldTimeEndInt>=newTimeEndInt)) return true;
					if ((newTimeBeginInt<=oldTimeBeginInt&&newTimeEndInt>=oldTimeBeginInt)||(newTimeBeginInt<=oldTimeEndInt&&newTimeEndInt>=oldTimeEndInt)) return true;
				}
			}	
		}
		
		
		return false;
	}
	@Override
	public void logAllOaMeetingRoomTaking() {
		// TODO Auto-generated method stub
		//记录所有单天的预订
		List l=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTaking t where t.status='A'  and ( (t.periodType=1 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')=CURDATE()) or (t.periodType=2 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')<=CURDATE()) or (t.periodType=3 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')<=CURDATE()) or (t.periodType=4 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')<=CURDATE()) ) ");
		
		OaMeetingRoomTaking task;
		for(int i=0;l!=null&&i<l.size();i++){
			task=(OaMeetingRoomTaking)l.get(i);
			Date orderDate = DateHelper.toDate(DateHelper.toString(task.getOrderDate(), "yyyyMMdd"), "yyyyMMdd");
			
			//被取消的，则不处理
			List values = new ArrayList();
			values.add(task.getId());
			values.add(orderDate);
			List l2=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTakingCancel t where  t.taskId=? and t.meetingDate=? ",values.toArray());
			if (l2!=null&&l2.size()>0){
				continue;
			}
			
			
			int diffd=DateHelper.getDiffDay(task.getOrderDate(), DateHelper.getToday());
			//单次的只记录今天的
			if (task.getPeriodType().intValue()==1){
				if (!orderDate.equals(DateHelper.getToday())) continue;
			}
			else if (task.getPeriodType().intValue()==2){
				//每次的
				if (orderDate.after(DateHelper.getToday())) continue;
			}else if (task.getPeriodType().intValue()==3){
				//每周的
				if (orderDate.after(DateHelper.getToday())||diffd%7!=0) continue;
			}else if (task.getPeriodType().intValue()==3){
				//每两周的
				if (orderDate.after(DateHelper.getToday())||diffd%14!=0) continue;
			}
			//
			task.setOrderDate(DateHelper.getToday());
			oaMeetingRoomLogService.addOaMeetingRoomLog(task); 
		}
		//更新所有被取消的
		StringBuffer sql=new StringBuffer();
		ArrayList values=new ArrayList();
		sql.append("update oa_meeting_room_log a set a.status='B' where exists (select 1 from oa_meeting_room_taking_cancel b where a.task_id=b.task_id and a.meeting_date=b.meeting_date)");
		oaMeetingRoomLogService.getEntityDao().getJdbcDao().update(sql.toString(), values.toArray());
		
		
	}
	@SuppressWarnings("unchecked")
	@Override
	public List findAllRoomTaskList(OaMeetingRoomQuery query) {
		// TODO Auto-generated method stub
			
		List values = new ArrayList();
		StringBuffer sql = new StringBuffer();
		sql.append(" select * from ( ");
		sql.append(" select a.id,a.name roomName,a.type,a.branch_company_id branchCompanyId,d.name branchCompanyName,a.status from  oa_meeting_room a ");				
		sql.append(" left join  system_branch_company d  on a.branch_company_id=d.id ");
		sql.append(" ) t ");
		
		
		sql.append(" where 1=1 and t.status=0  ");
		
		//values.add(query.getProjectId());
		   if(isNotEmpty(query.getBranchCompanyId())) {
	            sql.append(" and  t.branchCompanyId = ?");
	            values.add(query.getBranchCompanyId());
	        }
		   if(isNotEmpty(query.getId())) {
	            sql.append(" and  t.id = ? ");
	            
	            values.add(query.getId());

	        }
		   if(isNotEmpty(query.getName())) {
	            sql.append(" and  t.name like ? ");
	            
	            values.add("%"+query.getName()+"%");

	        }
	          if(isNotEmpty(query.getType())) {
	            sql.append(" and  t.type = ? ");
	            values.add(query.getType());
	        }  
	          if(isNotEmpty(query.getStatus())) {
		            sql.append(" and  t.status = ? ");
		            values.add(query.getStatus());
		        }     
		
		//查询所有有效会议室
		List l=oaMeetingRoomLogService.getEntityDao().getJdbcDao().findByQuery(sql.toString(),values.toArray(), new MapObjectRowMapper());
		
		//查询所有有效的预定，设置
        List lTask=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTaking t where t.status='A' and ( (t.periodType=1 and DATE_FORMAT(t.orderDate,'%Y-%m-%d')>=CURDATE()) or  t.periodType=2 or t.periodType=3 or t.periodType=4)");
        
        
        List cancelTask=getEntityDao().getHibernateTemplate().find("from OaMeetingRoomTakingCancel t where DATE_FORMAT(t.meetingDate,'%Y-%m-%d')>=CURDATE() ");
		
        Map cancelTaskMap=new HashMap();
        OaMeetingRoomTakingCancel cancel=null;
        try{
	        for(int i=0;i<cancelTask.size();i++){
	        	cancel=(OaMeetingRoomTakingCancel)cancelTask.get(i);
	        	cancelTaskMap.put(cancel.getTaskId().toString()+DateHelper.toString(cancel.getMeetingDate(), "yyyyMMdd"), cancel.getId());
	        }
        }catch(Exception ex){}
        
		OaMeetingRoomTaking oldTask;
		OaMeetingRoomTaking newTask;
		
		Date today=DateHelper.getToday();
		Date endDate=DateHelper.add(today, DateHelper.DAY, 31);
		for (int i=0;l!=null&&i<l.size();i++){
			Map m=(Map)l.get(i);
			//System.out.println("会议室:"+m);
			for (int iday=0;iday<30;iday++){
				Date d=DateHelper.add(today, DateHelper.DAY, iday);
				
				newTask=new OaMeetingRoomTaking();
				newTask.setRoomId((Integer)m.get("id"));
				newTask.setOrderDate(d);
				newTask.setBeginDt(d);
				newTask.setPeriodType(new Integer(1));
				newTask.setEndDt(DateHelper.toDate(DateHelper.toString(d,"yyyy-MM-dd")+" 23:59:59","yyyy-MM-dd HH:mm:ss"));
				
				
				int orderNum=0;
				for(int j=0;lTask!=null&&j<lTask.size();j++){
					oldTask=(OaMeetingRoomTaking)lTask.get(j);
					
					//如果任务有取消，则不做处理
					//if (cancelTaskMap.containsKey(oldTask.getId().toString()+DateHelper.toString(oldTask.getOrderDate(), "yyyyMMdd"))) continue;
					
					if (this.isConflict(newTask, oldTask,cancelTaskMap)){
						//System.out.println("有冲突..................................."+newTask.getOrderDate()+" id:"+newTask.getRoomId()+"=="+oldTask.getOrderDate()+" id: "+oldTask.getRoomId());
						orderNum++;					
					}
				}				
				if (orderNum>0) m.put("day"+(iday+1), Integer.toString(orderNum));
				else m.put("day"+(iday+1), "");
				m.put("day"+(iday+1)+"Value", DateHelper.toString(d,"yyyy-MM-dd"));
				
			}
		}
		
		return l; 
		
	}
}
